package org.grow.present.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.grow.present.domain.Bank;
import org.grow.present.dto.Msg;
import org.grow.present.dto.PageResults;
import org.grow.present.dto.QueryCondition;
import org.grow.present.mapper.BankMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/bank")
public class BankController {

    @Autowired
    private BankMapper bankMapper;

    @PostMapping("/query")
    public Msg<PageResults<Bank>> query(QueryCondition queryCondition) {
        IPage page = Page.of(queryCondition.getPageNum(), queryCondition.getPageSize());
        IPage paged = bankMapper.dynamicQuery(page, queryCondition);
        PageResults pageResults = PageResults.createByIPage(paged);
        return Msg.success().data(pageResults);
    }
}
